
CREATE TABLE [dbo].[Topic] (
	[TopicID] [int] IDENTITY (1000, 1) NOT NULL ,
	[Topic] [nvarchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
	[SubTopic] [nvarchar] (1000) COLLATE SQL_Latin1_General_CP1_CI_AS NULL 
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[Topic] ADD 
	CONSTRAINT [PK_Topic] PRIMARY KEY  CLUSTERED 
	(
		[TopicID]
	)  ON [PRIMARY] 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO



CREATE PROCEDURE [sp_InsertTopic]
/*
	Mult-purpose Article Search Capability	
	Version 0.6
	Coded By Zhang Xiaohua
	11/8/06
*/
(
	@Topic			nvarchar(100),
	@SubTopic		nvarchar(1000),
	@ReturnID		int=-1	output 
)
AS 
	INSERT INTO Topic (Topic, SubTopic)
	values (@Topic, @SubTopic);

	SELECT @ReturnID=@@IDENTITY;
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO

 CREATE PROCEDURE [sp_UpdateTopic] 
(
	@TopicID		integer,
	@Topic			nvarchar(100),
	@SubTopic		nvarchar(1000)
)
	AS
	SET NOCOUNT OFF;
	UPDATE Topic SET 
			Topic=@Topic,
			SubTopic=@SubTopic
	 WHERE TopicID=@TopicID;
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO




